package pl.jtb.ctl.tabory.dao.data.sl;

public enum UserRoleSL {

    ADMINISTRATOR(0L, "admin"), REGULAR(1L, "regular"), REPORTER(2L, "reporter");

    private UserRoleSL(Long id, String name) {
        this.id = id;
        this.name = name;
    }

    private Long id;
    private String name;

    public Long getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public static long getRoleId(String roleName) {
        for (UserRoleSL userRole : UserRoleSL.values()) {
            if (userRole.getName().equals(roleName)) {
                return userRole.getId();
            }
        }
        return -1;
    }

    public static UserRoleSL getUserRole(long id) {
        for (UserRoleSL userRole : UserRoleSL.values()) {
            if (userRole.getId().equals(id)) {
                return userRole;
            }
        }
        return null;
    }

}
